<?php

namespace App\Validators\Personnel;

use App\Validators\PassesValidator;
use \Prettus\Validator\Contracts\ValidatorInterface;
use \Prettus\Validator\LaravelValidator;

class DepartmentValidator extends LaravelValidator
{

    use PassesValidator;

    protected $rulesMessages=[
        'id.not_exists' => '该部门还有人员不能删除',
        'name.required' => '名称是必填的',
    ];

    protected $rules = [
        ValidatorInterface::RULE_CREATE => [
            'name' => 'required',
        ],
        ValidatorInterface::RULE_UPDATE => [
            'name' => 'required',
        ],
        "DELETE" => [
            'id' =>'not_exists:users,major_department_id|not_exists:user_department,department_id|not_exists:department,parent_id',
        ]
   ];
}
